﻿<UserControl x:Class="EmperialApps.WeatherSpark.Credits"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:EmperialApps.WeatherSpark"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             Foreground="{StaticResource PhoneForegroundBrush}"
             mc:Ignorable="d"
             d:DesignHeight="620"
             d:DesignWidth="480">

    <Grid x:Name="LayoutRoot"
          Margin="{StaticResource PhoneHorizontalMargin}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <local:NullToVisibilityConverter x:Key="NullToVisibility" />
        </Grid.Resources>

        <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                   Grid.Row="0"
                   Margin="0,0,0,6"
                   Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.Credits_header}"
                   TextWrapping="Wrap" />

        <phone:LongListSelector x:Name="CreditsList"
                                Grid.Row="1"
                                Margin="0,0,-48,0"
                                IsGroupingEnabled="True">
            <phone:LongListSelector.ListFooterTemplate>
                <DataTemplate>
                    <Grid Margin="{StaticResource PhoneVerticalMargin}" />
                </DataTemplate>
            </phone:LongListSelector.ListFooterTemplate>

            <phone:LongListSelector.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="0,6,0,12">
                        <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                                       FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                       Foreground="{StaticResource PhoneAccentBrush}"
                                       Text="{Binding Title}"
                                       TextWrapping="Wrap"
                                       Visibility="{Binding Title, Converter={StaticResource NullToVisibility}}" />
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                                       Text="{Binding Description}"
                                       TextWrapping="Wrap" />
                            <!-- DEBUG:
                            <TextBlock Style="{StaticResource PhoneTextSmallStyle}"
                                       Text="{Binding Link}"
                                       TextWrapping="Wrap" />
                            -->
                        </StackPanel>
                        <HyperlinkButton NavigateUri="{Binding Link}"
                                         TargetName="_blank" />
                    </Grid>
                </DataTemplate>
            </phone:LongListSelector.ItemTemplate>

            <phone:LongListSelector.GroupHeaderTemplate>
                <DataTemplate>
                    <TextBlock Style="{StaticResource PhoneTextTitle1Style}"
                               FontSize="{StaticResource PhoneFontSizeExtraLarge}"
                               Text="{Binding Group}" />
                </DataTemplate>
            </phone:LongListSelector.GroupHeaderTemplate>
        </phone:LongListSelector>
    </Grid>
</UserControl>
